package com.example.demo.two;

import com.example.demo.util.RabbitMQUtils;
import com.rabbitmq.client.Channel;
import org.junit.jupiter.api.Test;

import java.io.IOException;

/**
 * @author chensixiang chensixiang1234@gmail.com
 */
public class Worker01 {

    public static final String QUEUE_NAME = "hello";

    public static void main(String[] args) throws IOException {
        Channel channel = RabbitMQUtils.getChannel();
        System.out.println("C2等待接收消息......");
        channel.basicConsume(
                QUEUE_NAME,
                true,
                (consumerTag, message) -> {
                    System.out.println("接收到的消息 -> " + new String(message.getBody()));
                }, consumerTag -> {
                    System.out.println(consumerTag + " -> 消息被取消");
                });
    }
}
